package com.stox.ui.javafx.core.event.handler;

import javafx.geometry.Bounds;
import javafx.scene.Node;
import javafx.scene.layout.Region;

import com.stox.ui.javafx.core.widget.StoxStage;

public class BoundsInLocalPropertyChangeListener  extends AbstractPropertyChangeListener<Bounds> {
	
	public BoundsInLocalPropertyChangeListener(Region node) {
		super(node);
	}

	@Override
	public void changed(Bounds newValue, Node node) {
		Region region = (Region) node;
		Bounds bounds = StoxStage.getInstance().getContentPane().getBoundsInLocal();
		if(newValue.getHeight() > bounds.getHeight())
			region.setMaxHeight(bounds.getHeight());
		if(newValue.getWidth() > bounds.getWidth())
			region.setMaxWidth(bounds.getWidth());
	}
	
}
